<!--
 * @Description  :
 * @Autor        : guoxi
 * @Date         : 2022-06-16 10:16:50
 * @LastEditors  : Please set LastEditors
 * @LastEditTime : 2022-09-08 09:54:52
 * @FilePath     : \rpms\src\views\project\implementation\detail\index.vue
-->
<template>
  <div v-if="!isShow">
    <el-card>
      <div class="card-wrap">
        <el-page-header content="添加实施信息" @back="handleBack" />
        <div>
          <template v-if="!isApproval">
            <el-button @click="goBack">取消</el-button>
            <el-button
              v-if="!route.query.instanceId"
              type="primary"
              :loading="model.saveLoading"
              @click="handleSave"
              >保存</el-button
            >
            <el-button
              type="primary"
              :loading="model.saveLoading"
              @click="handleSubmit"
              >提交</el-button
            >
          </template>
          <!-- <template v-if="isApproval">
            <el-button type="primary" @click="reject">驳回</el-button>
            <el-button
              type="primary"
              :loading="model.saveLoading"
              @click="approve"
              >通过</el-button
            >
          </template> -->
        </div>
      </div>
    </el-card>
    <br />

    <el-card>
      <template #header>
        <div class="card-box-header">
          <span>项目基本信息</span>
          <div v-if="show1" @click="show1 = !show1" class="header-btn">
            收起
            <i class="el-icon-arrow-down"></i>
          </div>
          <div v-else @click="show1 = !show1" class="header-btn">
            展开
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </template>
      <div v-show="show1">
        <BasicsInfo :projectInfo="projectInfo" />
      </div>
    </el-card>
    <br />

    <el-card>
      <template #header>
        <div class="card-box-header">
          <span>项目实施计划</span>
          <div v-if="show2" @click="show2 = !show2" class="header-btn">
            收起
            <i class="el-icon-arrow-down"></i>
          </div>
          <div v-else @click="show2 = !show2" class="header-btn">
            展开
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </template>
      <div v-show="show2">
        <el-table
          :data="tableData"
          border
          :header-cell-style="{
            background: '#eef1f6',
            color: '#606266'
          }"
        >
          <template #empty>
            <el-empty :image-size="40" description="暂无数据"></el-empty>
          </template>
          <el-table-column type="index" label="序号" />
          <el-table-column prop="time" label="起止时间"></el-table-column>
          <el-table-column prop="content" label="研究内容"></el-table-column>
          <el-table-column prop="goal" label="预期目标"></el-table-column>
          <el-table-column prop="isDone" label="是否完成">
            <template #default="{ row }">
              {{ row.isDone === "1" ? "是" : "否" }}
            </template>
          </el-table-column>
          <el-table-column prop="doneTime" label="完成时间"></el-table-column>
          <el-table-column prop="doneDes" label="完成情况"></el-table-column>
          <el-table-column label="进度">
            <template #default="{ row }">
              {{ row.progress && row.progress + "%" }}
            </template>
          </el-table-column>
          <!-- <el-table-column prop="attachment" label="附件">
            <template #default="{ row }">
              <el-upload name="uploadFile" multiple :accept="acceptTypes" :action="uploadComUrl" :headers="uploadHeaders"
                :file-list="row.attachment" :on-preview="handlePreview"></el-upload>
            </template>
          </el-table-column> -->
          <el-table-column label="操作" width="220" fixed="right">
            <template #default="{ row, $index }">
              <span
                style="margin-right: 10px"
                v-if="route.query.mode !== 'look'"
                ><el-button type="text" @click="reset(row, $index)"
                  >重置</el-button
                >
                <el-button type="text" @click="edit(row, $index)"
                  >编辑</el-button
                ></span
              >
              <span style="margin-right: 10px" v-else>
                <el-button type="text" @click="edit(row, $index)"
                  >查看</el-button
                >
              </span>
              <el-button type="text" @click="openProcess(row, $index)"
                >实施过程记录</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-card>
    <br />

    <el-card v-if="route.query.instanceId">
      <template #header>
        <div class="card-box-header">
          <span> 专家评审意见</span>
          <div v-if="show3" @click="show3 = !show3" class="header-btn">
            收起
            <i class="el-icon-arrow-down"></i>
          </div>
          <div v-else @click="show3 = !show3" class="header-btn">
            展开
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </template>
      <div v-show="show3">
        <ExperReviewtList :projectInfo="projectInfo" />
        <BuildApproval :projectInfo="projectInfo" class="mg-top" />
      </div>
    </el-card>
    <br />

    <el-card v-if="route.query.instanceId">
      <template #header>
        <div class="card-box-header">
          <span> 流程状态</span>
          <div v-if="show5" @click="show5 = !show5" class="header-btn">
            收起
            <i class="el-icon-arrow-down"></i>
          </div>
          <div v-else @click="show5 = !show5" class="header-btn">
            展开
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </template>
      <div v-if="steps && steps.length">
        <el-collapse-transition>
          <status-info
            :currentStep="currentStep"
            :steps="steps"
            :isSkip="isSkipLx"
          />
        </el-collapse-transition>
      </div>
    </el-card>
    <br />
    <el-card v-if="route.query.instanceId">
      <template #header>
        <div class="card-box-header">
          <span> 流转记录</span>
          <div v-if="show6" @click="show6 = !show6" class="header-btn">
            收起
            <i class="el-icon-arrow-down"></i>
          </div>
          <div v-else @click="show6 = !show6" class="header-btn">
            展开
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </template>
      <div v-show="show6">
        <el-collapse-transition>
          <approval-info :activities="approveRecord" />
        </el-collapse-transition>
      </div>
    </el-card>
  </div>
  <el-dialog
    title="项目实施情况"
    v-model="model.dialogFormVisible"
    destroy-on-close
    width="45vw"
  >
    <el-form
      :model="model.formData"
      :disabled="route.query.mode === 'look'"
      ref="formRef"
      @submit.prevent
      :rules="formRules"
      label-width="100px"
    >
      <el-row>
        <el-col>
          <el-form-item label="起止时间">
            {{ model.formData.time }}
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col>
          <el-form-item label="研究内容">
            {{ model.formData.content }}
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col>
          <el-form-item label="预期目标">
            {{ model.formData.goal }}
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col>
          <el-form-item label="是否完成" prop="isDone">
            <el-select
              style="width: 100%"
              v-model="model.formData.isDone"
              clearable
              placeholder="请选择"
              value-key="id"
            >
              <el-option
                v-for="item in model.dones"
                :key="item.key"
                :label="item.label"
                :value="item.key"
              ></el-option>
            </el-select>
          </el-form-item> </el-col
      ></el-row>

      <el-row>
        <el-col>
          <el-form-item label="完成时间" prop="doneTime">
            <el-date-picker
              style="width: 100%"
              v-model="model.formData.doneTime"
              value-format="YYYY-MM-DD hh:mm:ss"
              type="date"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item label="进度" prop="progress">
            <el-input type="number" v-model="model.formData.progress">
              <template #append>%</template>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item label="完成情况" prop="doneDes">
            <el-input type="textarea" v-model="model.formData.doneDes" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col>
          <el-form-item label="附件">
            <!-- <el-upload
              name="uploadFile"
              multiple
              :accept="acceptTypes"
              :action="uploadComUrl"
              :headers="uploadHeaders"
              :on-success="handlelSuccess"
              :on-remove="handlelRemove"
              :on-error="handleError"
              :file-list="model.defaultFileList"
              :before-upload="beforeAvatarUpload"
              :on-preview="handlePreview"
            >
              <el-button size="small" type="primary">点击上传</el-button>
              <template #tip>
                <div class="el-upload__tip">
                  支持上传doc、docx、xls、xlsx、pdf、ppt、pptx、png、jpg、jpeg等格式文件,文件大小不得大于10M。
                </div>
              </template>
            </el-upload> -->
            <ecm-upload
              :files="model.defaultFileList"
              :docid="model.docid"
              @setFile="handlelSuccess"
            ></ecm-upload>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-row justify="end" v-if="route.query.mode !== 'look'">
      <el-button @click="model.dialogFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="handleDialogSubmit">确 定</el-button>
    </el-row>
  </el-dialog>
  <el-dialog
    title="实施过程记录"
    v-model="model.processVisible"
    destroy-on-close
    width="60vw"
  >
    <el-button
      v-if="route.query.mode !== 'look'"
      @click="add"
      type="primary"
      style="margin: 16px 0"
      >新增</el-button
    >
    <el-table
      :data="model.targetProcess.planProcessList"
      border
      :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
    >
      <el-table-column type="index" width="50" label="序号" />
      <el-table-column prop="comSituation" label="完成情况"></el-table-column>
      <el-table-column label="附件">
        <template #default="{ row }">
          <el-link
            v-for="(item, index) in row.processAttachmentArr"
            :key="index"
            @click="handlePreview(item)"
            >{{ item.fileName }}</el-link
          >
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="提交时间"></el-table-column>
      <el-table-column prop="createUserName" label="提交人"></el-table-column>
      <el-table-column label="操作" v-if="route.query.mode !== 'look'">
        <template #default="{ row, $index }">
          <el-button type="text" @click="editProcess(row)">编辑</el-button>
          <el-popconfirm
            confirm-button-text="确定"
            cancel-button-text="取消"
            icon="el-icon-info"
            icon-color="red"
            title="确定删除该条记录吗？"
            @confirm="deleteProcess(row, $index)"
          >
            <template #reference>
              <el-button v-auth="`document-scientific-del`" type="text"
                >删除</el-button
              >
            </template>
          </el-popconfirm>
          <!-- <el-button type="text" @click="deleteProcess(row)">删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>
  </el-dialog>

  <el-dialog
    title="编辑实施过程记录"
    v-model="model.processFormVisible"
    destroy-on-close
  >
    <el-form
      label-width="100px"
      :model="model.processFormData"
      ref="formRef2"
      @submit.prevent
      :rules="formRules2"
    >
      <el-row>
        <el-col>
          <el-form-item label="研究内容">
            {{ model.targetProcess.content }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item label="起止时间">
            {{ model.targetProcess.time }}
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col>
          <el-form-item label="完成情况" prop="comSituation">
            <el-input
              type="textarea"
              v-model="model.processFormData.comSituation"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col>
          <el-form-item label="附件">
            <ecm-upload
              :files="model.processFormData.processAttachmentArr"
              :docid="model.docid"
              @setFile="handlelSuccess2"
            ></ecm-upload>
            <!-- <el-upload
              name="uploadFile"
              multiple
              :accept="acceptTypes"
              :action="uploadComUrl"
              :headers="uploadHeaders"
              :on-success="handlelSuccess2"
              :on-remove="handlelRemove2"
              :on-error="handleError"
              :file-list="model.processFormData.processAttachmentArr"
              :before-upload="beforeAvatarUpload"
              :on-preview="handlePreview"
            >
              <el-button size="small" type="primary">点击上传</el-button>
              <template #tip>
                <div class="el-upload__tip">
                  支持上传doc、docx、xls、xlsx、pdf、ppt、pptx、png、jpg、jpeg等格式文件,文件大小不得大于10M。
                </div>
              </template>
            </el-upload> -->
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-row justify="end">
      <el-button @click="model.processFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="handleProcessSubmit">确 定</el-button>
    </el-row>
  </el-dialog>

  <el-dialog
    title=""
    v-model="model.secondConfirmVisible"
    destroy-on-close
    width="500px"
  >
    <p class="secont-tips">提交后将进入验收阶段，若项目仍在实施过程中，请点击取消，若项目确认进入验收阶段，请点击确定，并完成相应审批</p>
    <el-row justify="end">
      <el-button @click="model.secondConfirmVisible = false">取 消</el-button>
      <el-button type="primary" @click="handleSecondConfirm">确 定</el-button>
    </el-row>
  </el-dialog>

  <approveDialog
    v-if="approveDialogVisiable"
    :nodeId="nodeId"
    :flowType="model.flowType"
    @cancel="cancel"
    @sure="sureSubmit"
  ></approveDialog>
</template>

<script lang="ts" setup>
import ExperReviewtList from "/@/views/approval/detail/components/ExperReviewtList.vue";
import BuildApproval from "/@/views/approval/detail/components/BuildApproval.vue";
import approveDialog from "/@/components/approveDialog/index.vue";
import { storageLocal } from "/@/utils/storage";
import { ref, reactive } from "vue";
import { useRouter, useRoute } from "vue-router";
import BasicsInfo from "../../detail/components/BasicsInfo.vue";
import { cloneDeep } from "lodash-es";
import {
  getProjectInfo,
  updatePlan,
  submitStage,
  flowStart,
  flowSubmit,
  getApproveHistory
  // approveStage
} from "/@/api/project";
import NotifMessage from "/@/utils/message/notification";
// import { ElMessageBox } from "element-plus";
import { formatDate } from "/@/utils/format/fieldSignFormat";
// import { ElMessageBox } from "element-plus";
import { flowStatusObj } from "/@/components/StatusInfo/type";
import StatusInfo from "/@/components/StatusInfo/index.vue";
import ApprovalInfo from "/@/components/ApprovalInfo/index.vue";
import EcmUpload from "/@/components/ecmUpload/index.vue";
const router = useRouter();
const route = useRoute();
let tableData = ref([]);
let approveDialogVisiable = ref(false);
let show5 = ref<boolean>(true);
let show3 = ref<boolean>(true);
let show6 = ref<boolean>(true);
const steps = ref([]);
const approveRecord = ref([]);
const currentStep = ref(null);
const isSkipLx = route.query.isSkipLx;
const formRef = ref<HTMLFormElement | null>(null) as any;
const formRef2 = ref<HTMLFormElement | null>(null) as any;
const formRules = ref({
  isDone: [{ required: true, message: "请选择完成类型", trigger: "change" }],
  doneTime: [{ required: true, message: "请选择完成时间", trigger: "change" }],
  doneDes: [{ required: true, message: "请输入完成情况", trigger: "blur" }],
  progress: [{ required: true, message: "请输入进度", trigger: "blur" }]
});
const formRules2 = ref({
  comSituation: [{ required: true, message: "请输入完成情况", trigger: "blur" }]
});
const nodeId = route.query.nodeId ? route.query.nodeId : "ACT_010";
let model = reactive({
  processEdit: false,
  docid: window["ecmDocType"].project,
  flowType: "2028",
  userName: "",
  targetProcess: null,
  processVisible: false,
  processFormVisible: false,
  secondConfirmVisible:false,
  saveLoading: false,
  index: 0,
  dialogFormVisible: false,
  defaultFileList: [],
  dones: [
    { key: "1", label: "是" },
    { key: "0", label: "否" }
  ],
  processFormData: {
    createTime: "",
    createUserName: "",
    comSituation: "",
    processAttachmentArr: []
  },
  formData: {
    time: "",
    content: "",
    goal: "",
    isDone: "",
    doneTime: "",
    doneDes: "",
    attachment: [],
    progress: "",
    planProcessList: []
  }
});

const flowStartData = reactive({
  formBaseInfo: {
    billName: "",
    projectName: "",
    projectManageId: route.query.id,
    id: route.query.id,
    flowStartAttachmentArr: []
  },
  flowFormData: {
    businessId: route.query.id,
    flowTypeCode: "",
    nodeId: route.query.nodeId,
    projectManageId: route.query.id,
    remarks: "",
    saveState: "1"
  },
  formSubMap: {
    stageStatus: "3",
    flowType: "",
    assignee: null,
    opinion: ""
  }
});

const user = storageLocal.getItem("rdms-info");
model.userName = user?.name;

let show1 = ref<boolean>(true);
let show2 = ref<boolean>(true);

const flowPassData = reactive({
  formBaseInfo: {
    id: route.query.id,
    acceptUsers: null
  },
  flowFormData: {
    approvalComments: "",
    approvalResult: "",
    businessId: route.query.id,
    flowId: route.query.flowId,
    flowTypeCode: "",
    instanceId: route.query.instanceId,
    nodeId: route.query.nodeId,
    remarks: "",
    saveState: "1"
  },
  formSubMap: {
    stageStatus: "3",
    flowType: "",
    nodeId: route.query.nodeId,
    procInstId: route.query.instanceId,
    taskId: route.query.taskId,
    opinion: "",
    assignee: null,
    isChargehand: "1", //1：向下提交到下一步：0：回退到某一步
    specialReject: "0"
  },
  tmpStorage: {
    nodeId: route.query.nodeId,
    flowId: route.query.flowId,
    taskId: route.query.taskId,
    handlerId: null,
    valueJson: ""
  }
});

const flowPassSubmit = async params => {
  flowPassData.flowFormData.approvalComments = params.remark;
  flowPassData.flowFormData.approvalResult = "1"; //同意：1，不同意：0
  flowPassData.flowFormData.remarks = params.remark;
  flowPassData.flowFormData.flowTypeCode = model.flowType;
  flowPassData.formSubMap.opinion = ``;
  flowPassData.tmpStorage.valueJson = JSON.stringify(flowPassData.formSubMap);
  const info = storageLocal.getItem("rdms-info");
  const userId = info?.userId;
  flowPassData.tmpStorage.handlerId = userId;
  flowPassData.formBaseInfo.acceptUsers = params?.handlederId?.id || userId;
  flowPassData.formSubMap.assignee = params?.handlederId?.id || userId;
  flowPassData.formSubMap.isChargehand = "1";
  flowPassData.formSubMap.flowType = model.flowType;
  const { code, message } = await flowSubmit(flowPassData);
  if (code === 200) {
    NotifMessage.success(message);
    router.push("/approval/todo");
  } else {
    NotifMessage.error(message);
  }
};

const add = () => {
  model.processEdit = false;
  model.processFormData = {
    createTime: "",
    createUserName: "",
    comSituation: "",
    processAttachmentArr: []
  };
  model.processFormVisible = true;
};

//查询流程审批记录
const getApproveHistoryList = async () => {
  const instanceId = route.query.instanceId;
  if (instanceId) {
    const { code, data } = await getApproveHistory(instanceId);
    if (code === 200) {
      approveRecord.value = data;
    }
  }
};

const getStep = () => {
  const nodeId = route.query.nodeId ? route.query.nodeId : "ACT_010";
  steps.value = flowStatusObj[model.flowType];
  if (steps.value && steps.value.length) {
    steps.value.forEach((item, index) => {
      if (item.nodeId === nodeId) {
        currentStep.value = Number(index);
      }
    });
  }
};

const sureSubmit = async params => {
  approveDialogVisiable.value = false;
  model.saveLoading = false;
  const flag = await handleSave(false);
  if (!flag) {
    model.saveLoading = true;
    if (route.query.instanceId) {
      flowPassSubmit(params);
    } else {
      flowSumbitStart(params);
    }
  }
};

const flowSumbitStart = async params => {
  await submitStage(route.query.id);
  console.log("params", params);
  approveDialogVisiable.value = false;
  flowStartData.formBaseInfo.billName =
    projectInfo.value.projectName + "项目实施-审批流程";
  flowStartData.formBaseInfo.projectName = projectInfo.value.projectName;
  flowStartData.flowFormData.flowTypeCode = model.flowType;
  flowStartData.formBaseInfo.projectManageId = projectInfo.value.id + "";
  flowStartData.flowFormData.projectManageId = projectInfo.value.id + "";
  flowStartData.formSubMap.flowType = model.flowType;
  flowStartData.formSubMap.assignee = params?.handlederId?.id;
  flowStartData.flowFormData.remarks = params?.remark;
  const { code, message } = await flowStart(flowStartData);
  if (code === 200) {
    model.saveLoading = false;
    NotifMessage.success(message);
    goBack();
  }
};

const cancel = () => {
  approveDialogVisiable.value = false;
};

const handleProcessSubmit = () => {
  if (!model.targetProcess.planProcessList) {
    model.targetProcess.planProcessList = [];
  }
  if (!model.processEdit) {
    model.processFormData.createTime = formatDate(
      new Date(),
      "yyyy-mm-dd hh:ii:ss"
    );
    model.processFormData.createUserName = model.userName;
    model.targetProcess.planProcessList.push(model.processFormData);
  }

  model.processFormVisible = false;
};
const openProcess = item => {
  model.targetProcess = item;
  model.processVisible = true;
};
const editProcess = item => {
  model.processEdit = true;
  model.processFormData = item;
  model.processFormVisible = true;
};
const deleteProcess = (item, index) => {
  model.targetProcess.planProcessList.splice(index, 1);
};
// const approve = async () => {
//   model.saveLoading = true;
//   const { code, message } = await approveStage(route.query.id);
//   model.saveLoading = false;
//   if (code === 200) {
//     NotifMessage.success("审核成功");
//     goBack();
//   } else {
//     NotifMessage.error(message);
//   }
// };

const handlelSuccess = res => {
  model.defaultFileList = res.file;
  model.formData.attachment = res.file;
};

const handlelSuccess2 = res => {
  model.processFormData.processAttachmentArr = res.file;
  model.formData.attachment = res.file;
};

const handlePreview = (item: any) => {
  if (item.response) {
    window.open(
      `${location.origin}${location.pathname}#/online?uuidFile=${item?.response.data.uuidFile}&fileName=${item?.response.data.fileName}`
    );
  } else {
    window.open(
      `${location.origin}${location.pathname}#/online?uuidFile=${item.uuidFile}&fileName=${item.fileName}`
    );
  }
};

const handleBack = () => {
  router.replace("/project/implementation");
};

let projectInfo = ref(null);

const goBack = (): void => {
  router.push("/project/implementation");
};

const edit = (row, index) => {
  model.index = index;
  model.dialogFormVisible = true;
  model.formData = cloneDeep(row);
  model.defaultFileList = model.formData.attachment;
  // console.log(row);
};

const reset = row => {
  row.isDone = null;
  row.doneTime = "";
  row.doneDes = "";
  row.attachment = [];
};

const handleSecondConfirm = async () => {
  model.secondConfirmVisible = false;
  approveDialogVisiable.value = true;
}

const handleSubmit = async () => {
  model.saveLoading = true;
  model.secondConfirmVisible = true;
};

const handleSave = async (flag = true): Promise<any> => {
  try {
    model.saveLoading = true;
    const { code, message } = await updatePlan({
      id: route.query.id,
      projectPlans: tableData.value.map(el => {
        return {
          startTime: el.timeObj[0] + " 00:00:00",
          endTime: el.timeObj[1] + " 00:00:00",
          researchContent: el.content,
          goal: el.goal,
          projectId: route.query.id,
          done: el.isDone,
          doneDes: el.doneDes,
          doneTime: el.doneTime,
          attachment: JSON.stringify(el.attachment),
          progress: el.progress,
          planProcessList: el.planProcessList
        };
      })
    });
    model.saveLoading = false;
    if (code === 200) {
      if (flag) {
        NotifMessage.success(message);
        goBack();
        return true;
      } else {
        return false;
      }
    } else {
      NotifMessage.error(message);
    }
  } catch (err) {
    return true;
  }
};
const handleDialogSubmit = async () => {
  const isValid = await new Promise(resolve => formRef.value.validate(resolve));
  if (isValid) {
    tableData.value[model.index] = model.formData;
    model.dialogFormVisible = false;
  }
};

// 删除记录
const initProjectInfo = async () => {
  try {
    const queryId = route.query?.id ?? "";
    const { code, data } = queryId && (await getProjectInfo({ id: queryId }));
    if (code === 200) {
      console.log(data, "data");
      projectInfo.value = data;
      projectInfo.value.projectManageId = +route.query.id;
      projectInfo.value.reviewStageCode = 3;
      tableData.value = data.projectPlans.map(el => {
        if (el.planProcessList) {
          el.planProcessList.forEach(obj => {
            obj.processAttachmentArr &&
              obj.processAttachmentArr.map(file => {
                file["name"] = file.fileName;
              });
          });
        }
        return {
          time: el.startTime.split(" ")[0] + "至" + el.endTime.split(" ")[0],
          timeObj: [el.startTime.split(" ")[0], el.endTime.split(" ")[0]],
          content: el.researchContent,
          goal: el.goal,
          isDone: el.done,
          doneDes: el.doneDes,
          doneTime: el.doneTime,
          attachment: (el.attachment && JSON.parse(el.attachment)) || [],
          planProcessList: el.planProcessList,
          progress: el.progress
        };
      });
      getStep();
      // isSaveStatus.value= projectInfo.value.
    }
    // const res = await getPlanById(queryId);
    // if (res.code === 200) {
    //   const resData = JSON.parse(res.data);
    //   tableData.value = resData;
    //   console.log(res.data, "data");
    // }
  } catch (err) {
    console.log(err);
  }
};

initProjectInfo();
if (route.query.instanceId) {
  getApproveHistoryList();
}
const isApproval =
  route.query.mode === "approval" || route.query.mode === "look" ? true : false;
</script>

<style lang="scss" scoped>
.empt-content {
  height: calc(100vh - 200px);
  width: 100%;
}

.card-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;

  .header-btn {
    font-size: 14px;
    cursor: pointer;
  }
}
.secont-tips{
  margin:20px 0;
  line-height: 28px;
  font-size:16px
}
</style>
